﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefProdArchiveData" :model="stateProdArchiveData.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ArchiveIdId_FormItem" prop="Entity.ArchiveIdId" :label="$t('message.autotrans._Model_ProdArchiveData_ArchiveId')">
            <el-select v-model="stateProdArchiveData.vmModel.Entity.ArchiveIdId" clearable>
               <el-option v-for="item in stateProdArchiveData.AllArchiveIds" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Sn_FormItem" prop="Entity.Sn" :label="$t('message.autotrans._Model_ProdArchiveData_Sn')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdArchiveData_Sn')}), trigger: 'blur' }]" >
            <el-input v-model="stateProdArchiveData.vmModel.Entity.Sn" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Wo_FormItem" prop="Entity.Wo" :label="$t('message.autotrans._Model_ProdArchiveData_Wo')">
            <el-input v-model="stateProdArchiveData.vmModel.Entity.Wo" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductId_FormItem" prop="Entity.ProductId" :label="$t('message.autotrans._Model_ProdArchiveData_ProductId')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdArchiveData_ProductId')}), trigger: 'blur' }]" >
            <el-input v-model="stateProdArchiveData.vmModel.Entity.ProductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductCode_FormItem" prop="Entity.ProductCode" :label="$t('message.autotrans._Model_ProdArchiveData_ProductCode')">
            <el-input v-model="stateProdArchiveData.vmModel.Entity.ProductCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OpId_FormItem" prop="Entity.OpId" :label="$t('message.autotrans._Model_ProdArchiveData_OpId')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdArchiveData_OpId')}), trigger: 'blur' }]" >
            <el-input v-model="stateProdArchiveData.vmModel.Entity.OpId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OpCode_FormItem" prop="Entity.OpCode" :label="$t('message.autotrans._Model_ProdArchiveData_OpCode')">
            <el-input v-model="stateProdArchiveData.vmModel.Entity.OpCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_DataTag_FormItem" prop="Entity.DataTag" :label="$t('message.autotrans._Model_ProdArchiveData_DataTag')">
            <el-input v-model="stateProdArchiveData.vmModel.Entity.DataTag" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_DataName_FormItem" prop="Entity.DataName" :label="$t('message.autotrans._Model_ProdArchiveData_DataName')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdArchiveData_DataName')}), trigger: 'blur' }]" >
            <el-input v-model="stateProdArchiveData.vmModel.Entity.DataName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpLimit_FormItem" prop="Entity.UpLimit" :label="$t('message.autotrans._Model_ProdArchiveData_UpLimit')">
            <el-input v-model="stateProdArchiveData.vmModel.Entity.UpLimit" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_DataValue_FormItem" prop="Entity.DataValue" :label="$t('message.autotrans._Model_ProdArchiveData_DataValue')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdArchiveData_DataValue')}), trigger: 'blur' }]" >
            <el-input v-model="stateProdArchiveData.vmModel.Entity.DataValue" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_LowerLimit_FormItem" prop="Entity.LowerLimit" :label="$t('message.autotrans._Model_ProdArchiveData_LowerLimit')">
            <el-input v-model="stateProdArchiveData.vmModel.Entity.LowerLimit" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_SetParameter_FormItem" prop="Entity.SetParameter" :label="$t('message.autotrans._Model_ProdArchiveData_SetParameter')">
            <el-input v-model="stateProdArchiveData.vmModel.Entity.SetParameter" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onSubmitProdArchiveData"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

        <WtmButton @click="onCloseProdArchiveData"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageProductionManagementProdArchiveDataEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { prodarchivedataApi } from '/@/api/productionmanagement/prodarchivedata';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefProdArchiveData = ref();
const stateProdArchiveData = reactive({
    vmModel: {
	  Entity:{
        ArchiveIdId: null,
        Sn: '',
        Wo: '',
        ProductId: null,
        ProductCode: '',
        OpId: null,
        OpCode: '',
        DataTag: '',
        DataName: '',
        UpLimit: null,
        DataValue: '',
        LowerLimit: null,
        SetParameter: '',
        ID:null,
      },

	},
    
    AllArchiveIds: [] as any[],
});

// 取消
const onCloseProdArchiveData = () => {
    closeDialog();
};

// 提交
const onSubmitProdArchiveData = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefProdArchiveData.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            prodarchivedataApi().edit(stateProdArchiveData.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/ProductionManagement/ProdArchiveData/GetProdArchives',[],false).then(x=>{stateProdArchiveData.AllArchiveIds = x});
    if (ci.attrs["wtmdata"]) {
		stateProdArchiveData.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateProdArchiveData.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	prodarchivedataApi().get(stateProdArchiveData.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateProdArchiveData.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

